<html>
<head><meta charset="utf-8"><title>llvm alloc builtins · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/llvm.20alloc.20builtins.html">llvm alloc builtins</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="222878431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/llvm%20alloc%20builtins/near/222878431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/llvm.20alloc.20builtins.html#222878431">(Jan 15 2021 at 16:00)</a>:</h4>
<p>Hi, there's a comment on the magic alloc symbols (<code>__rust_alloc</code> and friends) which states they're special-cased in Rust's LLVM fork. It looks like they're just being added to <code>llvm/Analysis/MemoryBuiltins.h</code> as functions which allocate. Is this just to hint to llvm opt passes? or is there something else going on which I'm missing?</p>



<a name="222878598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/llvm%20alloc%20builtins/near/222878598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/llvm.20alloc.20builtins.html#222878598">(Jan 15 2021 at 16:01)</a>:</h4>
<p>I think it's just an optimization hint</p>



<a name="222879025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/llvm%20alloc%20builtins/near/222879025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/llvm.20alloc.20builtins.html#222879025">(Jan 15 2021 at 16:03)</a>:</h4>
<p>Fair enough, thanks :)</p>



<a name="222881885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/llvm%20alloc%20builtins/near/222881885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/llvm.20alloc.20builtins.html#222881885">(Jan 15 2021 at 16:20)</a>:</h4>
<p>Yeah, it's there so LLVM's alias analysis knows that their return values don't alias anything else, IIRC, as well as lets it know that it's an allocation function so the pass that removes allocations can work against it.</p>



<a name="222886323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/llvm%20alloc%20builtins/near/222886323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/llvm.20alloc.20builtins.html#222886323">(Jan 15 2021 at 16:46)</a>:</h4>
<p>I'd like to find a way to do this without the fork patch though</p>



<a name="222886446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/llvm%20alloc%20builtins/near/222886446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/llvm.20alloc.20builtins.html#222886446">(Jan 15 2021 at 16:46)</a>:</h4>
<p>seems like an attribute or something would suffice, but I haven't investigated this</p>



<a name="222891360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/llvm%20alloc%20builtins/near/222891360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/llvm.20alloc.20builtins.html#222891360">(Jan 15 2021 at 17:16)</a>:</h4>
<p>there is <code>__declspec(allocator)</code> but I think it's just a frontend  / debug thing. doesn't affect the optimizer :/</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>